<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>浩盛Todo - 任务回收站</title>
    {{ template "imports" }}
</head>
<body>
<div class="container">
    {{ template "nav" .}}
    <article>
        <h2 class="m-4 text-center">任务回收站</h2>
        <ul class="list-unstyled">
            {{ $dateTitle := "" }}
            {{ $today := .Date.Today }}
            {{ $yesterday := .Date.Yesterday }}
            {{ $tomorrow := .Date.Tomorrow }}
            {{ range .TaskList }}
                {{ if ne .Date $dateTitle }}
                    {{ $dateTitle = .Date }}
                    {{ if eq $dateTitle $today }}
                        <h3>今天</h3>
                    {{ else if eq $dateTitle $yesterday }}
                        <h3>昨天</h3>
                    {{ else if eq $dateTitle $tomorrow }}
                        <h3>明天</h3>
                    {{ else }}
                        <h3>{{ $dateTitle }}</h3>
                    {{ end }}
                {{ end }}
                <li class="task-item m-3 p-3 rounded">
                    <span class="d-none task-id">{{ .Id }}</span>
                    <span>{{ .Date }}</span>
                    <span>{{ .Name }}</span>
                    <a href="/task/check/{{ .Id }}" class="d-none float-end view-detail"
                       style="text-decoration: none">查看详情</a>
                </li>
            {{ end }}
        </ul>
    </article>
</div>
<script>
    $(function () {
        let taskItems = $(".task-item");
        taskItems.mouseenter(function () {
            let viewDetail = $(this).find(".view-detail");
            viewDetail.removeClass("d-none");
        });
        taskItems.mouseleave(function () {
            let viewDetail = $(this).find(".view-detail");
            viewDetail.addClass("d-none");
        });
        taskItems.click(function () {
            let taskId = $(this).find(".task-id").html();
            location.href = "/task/check/" + taskId;
        });
    });
</script>
</body>
</html>